home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_200 / 285_01 / allocate.c < prev    next >
Text File  |  1990-07-08  |  2KB  |  52 lines

  1. /* Allocate and clear storage for bison,
  2.    Copyright (C) 1984 Bob Corbett and Free Software Foundation, Inc.
  3.  
  4. BISON is distributed in the hope that it will be useful, but WITHOUT ANY
  5. WARRANTY.  No author or distributor accepts responsibility to anyone
  6. for the consequences of using it or for whether it serves any
  7. particular purpose or works at all, unless he says so in writing.
  8. Refer to the BISON General Public License for full details.
  9.  
  10. Everyone is granted permission to copy, modify and redistribute BISON,
  11. but only under the conditions described in the BISON General Public
  12. License.  A copy of this license is supposed to have been given to you
  13. along with BISON so you can know your rights and responsibilities.  It
  14. should be in a file named COPYING.  Among other things, the copyright
  15. notice and this notice must be preserved on all copies.
  16.  
  17.  In other words, you are welcome to use, share and improve this program.
  18.  You are forbidden to forbid anyone else to use, share and improve
  19.  what you give them.   Help stamp out software-hoarding!  */
  20.  
  21. /*
  22.     prototypeing and TurboC defs
  23.     1/5/88 DrH
  24. */
  25. #include <stdio.h>
  26.  
  27. #ifdef TURBOC
  28. #include <alloc.h>
  29. #else
  30. #include <malloc.h>
  31. #endif
  32.  
  33. #include "allocate.h"
  34.  
  35. extern void done(int) ;
  36.  
  37. char *
  38. mallocate(n)
  39. register unsigned n;
  40. {
  41.   register char *block;
  42.  
  43.   block = (char *) calloc( n, 1);
  44.   if (block == NULL)
  45.     {
  46.       fprintf(stderr, "bison: memory exhausted\n");
  47.       done(1);
  48.     }
  49.  
  50.   return (block);
  51. }
  52.